//package com.cj.user.service.mybatis;
//
//import com.cj.user.service.mybatis.mapper.OrderMapper;
//import com.cj.user.service.mybatis.mapper.UserMapper;
//import org.springframework.beans.factory.support.AbstractBeanDefinition;
//import org.springframework.beans.factory.support.BeanDefinitionBuilder;
//import org.springframework.beans.factory.support.BeanDefinitionRegistry;
//import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
//import org.springframework.core.type.AnnotationMetadata;
//import org.springframework.core.type.classreading.MetadataReader;
//import org.springframework.core.type.classreading.MetadataReaderFactory;
//import org.springframework.core.type.filter.TypeFilter;
//
//import java.io.IOException;
//
///**
// * @Author cheng jun
// * @Description:
// * @Date 2021/7/18 23:15
// */
//public class ImportBeanDefinitionRegistrarDemo implements ImportBeanDefinitionRegistrar {
//
//    @Override
//    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
//        String path = "com.kanq.service.mybatis.mapper";
//        com.kanq.service.mybatis.ScannerDemo scannerDemo = new com.kanq.service.mybatis.ScannerDemo(registry);
//        scannerDemo.addIncludeFilter(new TypeFilter() {
//            @Override
//            public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
//                return true;
//            }
//        });
//        scannerDemo.scan(path);
//
//        AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition().getBeanDefinition();
//        beanDefinition.setBeanClass(com.kanq.service.mybatis.FactoryBeanDemo.class);
//        beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(UserMapper.class);
//        registry.registerBeanDefinition("userMapper", beanDefinition);
//
//        AbstractBeanDefinition beanDefinition1 = BeanDefinitionBuilder.genericBeanDefinition().getBeanDefinition();
//        beanDefinition1.setBeanClass(com.kanq.service.mybatis.FactoryBeanDemo.class);
//        beanDefinition1.getConstructorArgumentValues().addGenericArgumentValue(OrderMapper.class);
//        registry.registerBeanDefinition("orderMapper", beanDefinition1);
//    }
//}
